dataSource {
    pooled = true
}

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "validate" // one of 'create', 'create-drop', 'update', 'validate', ''
            driverClassName = "com.mysql.jdbc.Driver"
            dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            url = "jdbc:mysql://localhost/myoa?useUnicode=true&characterEncoding=UTF-8"
            username = "root"
            password = ""
            //logSql = true      //输出Hibernate生成的SQL语句

        }
    }

    test {
        dataSource {
            dbCreate = "update"
            driverClassName = "org.h2.Driver"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
            username = "sa"
            password = ""
            properties {
                maxActive = -1
                minEvictableIdleTimeMillis = 1800000
                timeBetweenEvictionRunsMillis = 1800000
                numTestsPerEvictionRun = 3
                testOnBorrow = true
                testWhileIdle = true
                testOnReturn = true
                validationQuery = "SELECT 1"
            }
        }
    }

    production {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
            driverClassName = "com.mysql.jdbc.Driver"
            dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            url = "jdbc:mysql://2.2.2.2/myoa?useUnicode=true&characterEncoding=UTF-8"
            username = "root"
            password = "1234"

            //解决数据库连接池长期不用超时的问题
            properties {
                timeBetweenEvictionRunsMillis = 1000 * 60 * 60 * 3  //每3小时检查一次
                minEvictableIdleTimeMillis = 1000 * 60 * 60 * 3     //把超过3小时的空闲连接激活一次
                //这样最差的情况，一个连接最多空闲6小时，而MySQL配置的是8小时断开
            }
        }
    }
}
